{__NOLAYOUT__}
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport"
		  content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
	<title>提现</title>
	{include file="public/script" /}
</head>
<body>
	<div class="sectionH  sectionH2 mui-clearfix">
		<header class="mui-bar mui-bar-nav" style="">
			<a class="mui-icon mui-icon-left-nav  mui-pull-left" href="javascript:history.back(-1)" style="color: #727272;"></a>
			<h1 class="mui-title">提现</h1>
			<!--<a class="mui-icon mui-pull-right right1" href="assets-1.html"><img src="images/icon_setting.png"/></a>-->
		</header>
	</div>
	<div class="kong1"></div>
	<div class="tixian_section1">
		<div class="container">
			<form action="">
				<div class="f1 mui-clearfix">
					<span class="s1">提现至</span>
					<select name="type">
						<option value="1">微信</option>
						<option value="2">支付宝</option>
						<option value="3">银行卡</option>
					</select>
				</div>
				<div class="f1 mui-clearfix">
					<span class="s1">提现账号</span>
					<input name="account" maxlength="50" type="text" placeholder="请输入提现账号"/>
				</div>
				<div class="f1 mui-clearfix">
					<span class="s1">账号姓名</span>
					<input name="name" type="text" maxlength="20" placeholder="请输入账号姓名"/>
				</div>
				<div class="f2 mui-clearfix">
					<p class="p1">提现金额</p>
					<div class="ssg mui-clearfix">
						<span>¥</span> <input maxlength="11" autocomplete="off" name="money" type="number" placeholder="请输入提现金额"/>
					</div>
				</div>
				<div class="f3 mui-clearfix">
					<span class="s1">可提现金额 ¥ {$money}</span>
					<span id="all_withdraw" data="{$money}" class="s2">全部提现</span>
				</div>
				<div class="sub">
					<input type="button" style="color: #fff;" value="提现"/>
				</div>
			</form>
		</div>
	</div>
	
</body>
<script>
	$("#all_withdraw").click(function(){
        $("input[name=money]").val($(this).attr('data'));
	});
    $('.sub').click(function () {
        if($('.sub').hasClass('sending')){
            mui.toast('提现申请提交中...');
            return false;
        }
        var type=$("select[name=type]").val();
        var account=$("input[name=account]").val();
        if(account==''){
            mui.alert('请输入提现账号');
            return false;
		}
        var name=$("input[name=name]").val();
        if(name==''){
            mui.alert('请输入账号姓名');
            return false;
        }
        var money=$("input[name=money]").val();
        var max = {$money};
        money = parseFloat(money);
        if(isNaN(money) || money < 0.01){
            mui.alert('请输入提现金额');
            return false;
		}
		if(money>max){
            mui.alert('可提现余额不足');
            return false;
		}
        $.ajax({
            type:'post',
            url:"{:url('User/withdraw')}",
            data:{type:type,account:account,name:name,money:money},
            cache:false,
            dataType:'JSON',
            success:function(data){
                if(data.result_code==='0000'){
                    mui.alert('提现申请提交成功','',function(){
                        window.history.back();
                    });
                }else if(data.result_code==='1111'){
                    mui.alert('请登录','',function(){
                        window.location.href='/Login/login';
                    });
                }else{
                    mui.alert(data.result_info);
                    $(".sub").removeClass('sending');
                }

            },
            error:function(e){
                $(".sub").removeClass('sending');
            },
            beforeSend:function(e){
                $(".sub").addClass('sending');
            }
        });
    });

</script>
</html>